﻿#pragma once
#include "SMTBasics.h"
#include <QDebug>
#include <QDateTime>
#include <QDir>
#include <QFile>


void simpleLog2File(QString fileName, QString body)
{
	QDateTime current_date_time = QDateTime::currentDateTime();
	QString current_date = current_date_time.toString("yyyy.MM.dd hh:mm:ss.zzz");

	QDir* TEST = new QDir;
	bool exist = TEST->exists("log");
	if (!exist)
		bool ok = TEST->mkdir("log");
	QString fileName1 = "log/" + fileName;

	QFile file(fileName1);
	if (!file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append))
	{
		qCritical() << "logFile open fail!" << endl;
	}
	QTextStream in(&file);
	current_date += ":" + body;
	in << current_date << "\n";
	file.close();
	delete TEST;
}
